(global-set-key [(control ?.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
"Store cursorposition _fast_ in a register.
Use ska-jump-to-register to jump back to the stored
position."
(interactive)
(setq zmacs-region-stays t)
(point-to-register 8))

(defun ska-jump-to-register()
"Switches between current cursorposition and position
that was stored with ska-point-to-register."
(interactive)
(setq zmacs-region-stays t)
(let ((tmp (point-marker)))
(jump-to-register 8)
(set-register 8 tmp)))


(defun wr-recursive-count-words (region-end)
"Number of words between point and REGION-END."
(if (and (< (point) region-end)
(re-search-forward "\\w+\\W*" region-end t))
(1+ (wr-recursive-count-words region-end))
0))
(defun wr-count-words-region (beginning end)
"Print number of words in the region.
Words are defined as at least one word-constituent
character followed by at least one character that is
not a word-constituent. The buffer's syntax table
determines which characters these are."
(interactive "r")
(message "Counting words in region ... ")
(save-excursion
(goto-char beginning)
(let ((count (wr-recursive-count-words end)))
(cond ((zerop count)
(message
"The region does NOT have any words."))
((= 1 count)
(message "The region has 1 word."))
(t
(message
"The region has %d words." count))))))


;;这也忘了是从哪弄来的了
;;功能是将当前行设为本页第一行，同终端下的clear命令有点相似
(defun wr-line-to-top-of-window ()
"Move the line point is on to top of window."
(interactive)
(recenter 0))


;; Convert DOS cr-lf to UNIX newline
(defun dos-unix () (interactive) (goto-char (point-min))
  (while (search-forward "\r\n" nil t) (replace-match "\n")))

;; Convert UNIX newline to DOS cr-lf
(defun unix-dos () (interactive) (goto-char (point-min))
  (while (search-forward "\n" nil t) (replace-match "\r\n")))

;; Replace all tab with four blank spaces
(defun notab () (interactive)  (goto-char (point-min))
  (while (search-forward "\t" nil t) (replace-match "    ")))


;; eshell scroll smoothy
(setq scroll-margin 0
      scroll-conservatively 10000)

;;全屏
;(defun my-fullscreen ()
;  (interactive)
;  (x-send-client-message
;   nil 0 nil "_NET_WM_STATE" 32
;   '(2 "_NET_WM_STATE_FULLSCREEN" 0)))

;(defun w32-restore-frame ()
;     "Restore a minimized frame"
;      (interactive)
;      (w32-send-sys-command 61728))
;  (defun w32-maximize-frame ()
;      "Maximize the current frame"
;       (interactive)
;       (w32-send-sys-command 61488))
;  (w32-maximize-frame)

